package com.heima.feigns;

import com.heima.feigns.config.HeimaFeignAutoConfiguration;
import com.heima.feigns.fallback.WemediaFeignFallback;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmNews;
import com.heima.model.wemedia.pojos.WmUser;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;


@FeignClient(value = "leadnews-wemedia" , fallbackFactory = WemediaFeignFallback.class , configuration = HeimaFeignAutoConfiguration.class)
public interface WemediaFeign {

    /**
     * 根据传递名字查询自媒体用户是否存在
     * @param name
     * @return
     */
    @GetMapping("/api/v1/user/findByName/{name}")
    ResponseResult<WmUser> findByName(@PathVariable("name") String name);


    /**
     * 添加自媒体用户
     * @return
     */
    @PostMapping("/api/v1/user/save")
    ResponseResult<WmUser> addWmUser(@RequestBody WmUser wmUser);


    /**
     * 根据id查询文章
     * @param id
     * @return
     */
    @ApiOperation(value = "根据id查询单篇文章")
    @GetMapping("/api/v1/news/one/{id}")
    ResponseResult<WmNews> findNewById(@PathVariable("id") Integer id);

    /**
     * 修改文章的状态
     * @param wmNews
     * @return
     */
    @PutMapping("/api/v1/news/update")
    ResponseResult updateWmNews(@RequestBody WmNews wmNews);


}
